home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
404 Jogos
/
CLJG.iso
/
Aventura
/
FireMan.swf
/
scripts
/
frame_1179
/
PlaceObject2_276_1146
/
CLIPACTIONRECORD onClipEvent(enterFrame).as
next >
Wrap
Text File
|
2008-09-12
|
14KB
|
574 lines
onClipEvent(enterFrame){
function hitPlatforms()
{
var u;
u = suelo = sueloI = sueloD = false;
i = -9;
while(i <= 0)
{
sueloI = sueloI || mapa.hitTest(_X + i,_Y,true);
i++;
}
i = 1;
while(i <= 9)
{
sueloD = sueloD || mapa.hitTest(_X + i,_Y,true);
i++;
}
if(sueloI && wallizq() && !sueloD && !techo)
{
return undefined;
}
if(sueloD && wallder() && !sueloI && !techo)
{
return undefined;
}
suelo = sueloI || sueloD;
if(suelo)
{
falling = false;
currenthigh = 0;
techo = false;
if(s)
{
landing.start();
s = false;
}
j = -15;
while(j <= 15)
{
i = -9;
while(i <= 9)
{
if(mapa.hitTest(_X + i,_Y + j,true) && !mapa.hitTest(_X + i,_Y + j - 1,true))
{
u = true;
break;
}
i++;
}
if(u)
{
break;
}
j++;
}
_Y = _Y + j;
j = vertical = 0;
}
return undefined;
}
function roof()
{
var u = techo = false;
i = -3;
while(i <= 3)
{
if(mapa.hitTest(_X + i,_Y - 30,true))
{
u = techo = true;
break;
}
i++;
}
return u;
}
function gridx(a)
{
return int(a / GRIDSIZE);
}
function gridy(b)
{
if(b >= 0)
{
return int(b / GRIDSIZE);
}
return Math.floor(b / GRIDSIZE);
}
function render()
{
if(!death)
{
scrollspeed = 0;
if(this.hitTest(_root.scrollmask))
{
doscroll = true;
}
if(_root.topeizq._x >= 0 && horizontal < 0 || _root.topeder._x <= 256 && horizontal > 0)
{
doscroll = false;
}
if(doscroll)
{
_X = lastX;
scrollspeed = setSpeed() + _root.windx;
}
lastX = _X;
lastY = _Y;
if(timerdamage == 0 && hitted && !invisible)
{
timerdamage = FLASHTIME;
timerinvisible = INVISIBLETIME;
keys = false;
_root.currentdamage += DAMAGE;
barra.gotoAndStop(_root.currentdamage + 1);
_parent.fhitted.start();
if(rising || jumping)
{
vertical = 0.5;
falling = true;
}
}
if(timerdamage > 0)
{
flashing = true;
timerdamage--;
if(_xscale < 0 && !wallder())
{
if(doscroll)
{
scrollspeed = hforce / 2;
}
else
{
horizontal = hforce / 2;
}
}
if(_xscale > 0 && !wallizq())
{
if(doscroll)
{
scrollspeed = hforce / 2 * -1;
}
else
{
horizontal = hforce / 2 * -1;
}
}
}
if(flashing && timerdamage == 0)
{
flashing = false;
keys = true;
timerinvisible = INVISIBLETIME;
invisible = true;
}
if(invisible)
{
timerinvisible--;
timerinvisible % 2 != 0 ? (_visible = false) : (_visible = true);
}
if(timerinvisible <= 0 && invisible)
{
invisible = false;
hitted = false;
_visible = true;
}
if(_root.currentdamage + 1 >= MAXDAMAGE)
{
death = true;
barra.gotoAndStop(MAXDAMAGE);
_root.fdeath.start();
}
DAMAGE = 0;
if(!shooting && abletoshoot)
{
if(Key.isDown(SHOOT) && keys)
{
justshoot = true;
abletoshoot = false;
}
else
{
justshoot = false;
}
}
if(justshoot && !shooting)
{
if(_xscale > 0)
{
shoot1._x = _X + 41;
}
else
{
shoot1._x = _X - 41;
}
if(!vertical)
{
shoot1._y = _Y - 14;
}
else
{
shoot1._y = _Y - 20;
}
shoot1._visible = true;
if(_xscale > 0)
{
shoot1.dx = Math.abs(shoot1.dx);
shoot1._xscale = Math.abs(shoot1._xscale);
}
if(_xscale < 0)
{
shoot1.dx = Math.abs(shoot1.dx) * -1;
shoot1._xscale = Math.abs(shoot1._xscale) * -1;
}
blast.start();
shooting = true;
justshoot = false;
}
if(!shooting && !abletoshoot)
{
if(!Key.isDown(SHOOT))
{
abletoshoot = true;
}
}
x = setSpeed();
if(!flashing)
{
horizontal = x;
}
if(vertical == 0 && Key.isDown(ARRIBA) && upreleased && keys)
{
vertical = vforce * -1;
horizontal += platform.dx;
platformscroll = 0;
rising = true;
upreleased = false;
salto.start();
}
if(!falling && !uprelease)
{
if(!Key.isDown(ARRIBA))
{
upreleased = true;
}
}
if(rising)
{
if(roof())
{
falling = true;
startfall = true;
rising = false;
}
if(currenthigh < MAXJUMP && Key.isDown(ARRIBA) && !upreleased && !flashing)
{
if(roof())
{
startfall = true;
falling = true;
rising = false;
}
if(currenthigh < vforcei)
{
vertical = - Math.abs(vforcei);
}
else
{
vertical = - Math.abs(vforce);
}
currenthigh += Math.abs(vertical);
}
else
{
vertical *= gravity;
currenthigh += Math.abs(vertical);
if(Math.abs(vertical) < 1)
{
startfall = true;
falling = true;
rising = false;
}
}
}
if(Key.isDown(SLIDEKEY) && !rising && !falling && keys && slidereleased)
{
if(_xscale < 0 && !wallizq())
{
slideLeft = true;
slideRight = false;
}
if(_xscale > 0 && !wallder())
{
slideLeft = false;
slideRight = true;
}
slide = slideLeft || slideRight;
slidereleased = false;
}
if(slide && slidetimer == 0)
{
slidetimer = SLIDETIME;
}
if(slide && slidetimer > 0)
{
slidetimer--;
if(slidetimer == 0 || Key.isDown(IZQ) && slideRight || Key.isDown(DER) && slideLeft || falling || wallizq() && slideLeft || wallder() && slideRight)
{
slide = slideLeft = slideRight = slidetimer = 0;
}
}
if(!Key.isDown(SLIDEKEY) && !slidereleased)
{
slidereleased = true;
}
if(falling)
{
s = true;
if(startfall)
{
vertical = Math.abs(vforcei / 2) * accel;
startfall = false;
}
else
{
vertical = Math.abs(vertical) * accel;
}
if(vertical > MAXVERTICAL)
{
vertical = MAXVERTICAL;
}
platformscroll = 0;
hitPlatforms();
if(_Y >= 245)
{
death = true;
_root.fdeath.start();
}
}
if(tornado)
{
floating = true;
playtornado = true;
vertical2 += vforce;
if(vertical2 > MAXVERTICAL)
{
vertical2 = MAXVERTICAL / 6;
}
}
else
{
playtornado = false;
}
if(floating)
{
if(tornado)
{
vertical = - vertical2;
}
else
{
vertical = -4;
floating = false;
falling = false;
rising = true;
startfall = true;
vertical2 = 0;
}
}
if(playtornado && !soundtrigged)
{
_root.wind04.setVolume(100);
_root.wind04.start();
u = 100;
soundtrigged = true;
}
if(soundtrigged && !playtornado && u > 0)
{
u -= 5;
_root.wind04.setVolume(u);
if(u == 0)
{
_root.wind04.stop();
playtornado = true;
soundtrigged = false;
}
}
tornado = false;
if(_root.windx)
{
horizontal += _root.windx;
}
_Y = _Y + vertical + platform.dy;
if(horizontal < 0 && !wallizq() || horizontal > 0 && !wallder())
{
_X = _X + horizontal;
}
drawframe();
x1 = LastX - platform._x;
x2 = _X - platform._x;
if(!falling && !rising)
{
hitPlatforms();
if(!suelo)
{
vertical = 2;
falling = true;
}
}
}
else
{
drawframe();
vertical = horizontal = doscroll = scrollspeed = 0;
if(!f)
{
_root.fade.begin = true;
f = true;
}
}
}
function wallizq()
{
var u = false;
var t = !slide ? 12 : 20;
i = -24;
while(i < -15)
{
if(mapa.hitTest(_X - t,_Y + i,true))
{
u = true;
break;
}
i++;
}
return u;
}
function wallder()
{
var u = false;
var t = !slide ? 12 : 20;
i = -24;
while(i < -15)
{
if(mapa.hitTest(_X + t,_Y + i,true))
{
u = true;
break;
}
i++;
}
return u;
}
function setSpeed()
{
if(slideLeft && !rising)
{
forward = true;
backward = false;
if(horizontal == 0)
{
return hforce * -1;
}
return hforce * -1.5;
}
if(slideRight && !rising)
{
forward = false;
backward = true;
if(horizontal == 0)
{
return hforce;
}
return hforce * 1.5;
}
if(Key.isDown(DER) && keys && !wallder())
{
forward = false;
backward = true;
if(horizontal == 0)
{
return hforcei;
}
return hforce;
}
if(Key.isDown(IZQ) && keys && !wallizq())
{
forward = true;
backward = false;
if(horizontal == 0)
{
return hforcei * -1;
}
return hforce * -1;
}
return 0;
}
function drawFrame()
{
if(victory)
{
this.gotoAndStop("victory");
return undefined;
}
if(death)
{
this.gotoAndStop("death");
return undefined;
}
if(flashing)
{
this.gotoAndStop("hitted");
return undefined;
}
if(lastX != _X)
{
!forward ? (_xscale = Math.abs(_xscale)) : (_xscale = Math.abs(_xscale) * -1);
}
if(!shooting)
{
if(lastY > _Y && rising)
{
this.gotoAndStop("jump");
_root.estado = 3;
return undefined;
}
}
else if(lastY > _Y && rising)
{
this.gotoAndStop("attackJ");
_root.estado = 4;
return undefined;
}
if(lastY < _Y && falling || floating)
{
this.gotoAndStop("fall");
_root.estado = 5;
return undefined;
}
if(slide)
{
this.gotoAndStop("slide");
_root.estado = 6;
return undefined;
}
if(shooting)
{
if(horizontal != _root.windx)
{
this.gotoAndStop("attackRU");
sprite.gotoAndPlay(frame);
_root.estado = 2;
return undefined;
}
}
else if(horizontal != _root.windx)
{
this.gotoAndStop("run");
_root.estado = 1;
return undefined;
}
if(shooting)
{
this.gotoAndStop("attackST");
}
else
{
this.gotoAndStop("standing");
}
}
render();
frame = sprite._currentframe;
}